import { defineStore } from 'pinia'

// 第一种写法 包含state,getters,actions写法
export const useStore = defineStore('book',

    {
        // 唯一数据源
        state: () => ({
            book: [
                {
                    volumeId: '15353378',//目录大章节id
                    libers: "45309722", //章节id
                    books: "3381946", //书本id
                    coverImg:"http://cdn.static.17k.com//book//189x272//46//19//3381946.jpg-180x240?v=1638258025000",//书本封面
                    bookName:"风起龙城",//书名
                    bookEnd:"完结",
                    font: "LanTing",//字体
                    fontheigth: 20,//字间距
                    fontsize: 14,//字体大小
                    hsla: 0, //第一个参数
                    hslb: 0, //第二个参数
                    hslc: 80, //第三个参数
                    hsld: 0, //字体第一个参数
                    hsle: 0, //字体第二个参数
                    hslf: 100, //字体第三个参数
                    bacflag: 0, //切换主题颜色
                    bookrack:false,//是否加入书库
                    segment: [//段评
                        {
                            libers: '45309722',//章节id
                            index: '0',//章节下标
                            pindex: '0',//段落下标
                            talk: [
                                {
                                    name: '吃瓜者',//用户名
                                    userimg: 'https://i1.hdslb.com/bfs/face/4add3acfc930fcd07d06ea5e10a3a377314141c2.jpg@240w_240h_1c_1s.webp',//用户头像
                                    content: '你好世界',//内容
                                    time1: '2022-01-01',//toLocaleDateString()
                                    time2: '16:15:25'//toLocaleTimeString()
                                }
                            ]
                        }
                    ],
                    chapterlists: [//章评
                        {
                            libers: '45309722',//章节id
                            talk: [
                                {
                                    name: '吃瓜者',//用户名
                                    userimg: 'https://i1.hdslb.com/bfs/face/4add3acfc930fcd07d06ea5e10a3a377314141c2.jpg@240w_240h_1c_1s.webp',//用户头像
                                    content: '你好世界',//内容
                                    time1: '2022-01-01',//toLocaleDateString()
                                    time2: '16:15:25'//toLocaleTimeString()
                                }
                            ]
                        }
                    ],
                    bookreview: [//书评
                        {
                            talk: [
                                {
                                    name: '吃瓜者',//用户名
                                    userimg: 'https://i1.hdslb.com/bfs/face/4add3acfc930fcd07d06ea5e10a3a377314141c2.jpg@240w_240h_1c_1s.webp',//用户头像
                                    content: '你好世界',//内容
                                    time1: '2022-01-01',//toLocaleDateString()
                                    time2: '16:15:25'//toLocaleTimeString()
                                }
                            ]
                        }
                    ]

                }
            ],
            shophistory:[],//商城历史搜索
            shopnum:0,//购物车数量
            shopcar:[],//购物车商品列表
            caihistory:[],
            immediatelybuy:[],//购物结算列表
            follow:[],
            address:[],//收货地址
            search:'',
            scrolltop:"",
            order:[],//订单
            noorder:[],//不结算
            delivergoods:[],//发货
            evaluated:[],//评价
            mycomment:[],//我的评价
        }),



        persist: {
            enabled: true, // 这个配置代表存储生效，而且是整个store都存储
            // storage: localStorage,
            strategies: [
                // { storage: sessionStorage, paths: ['books'] }, // 字段用sessionStorage存储
                { storage: localStorage, paths: ['book'] }, // 字段用 localstorage存储
            ],
        }
    })